package com.qf.service.impl;

import com.qf.dto.Md5;
import com.qf.dto.UsersDto;
import com.qf.mapper.UsersMapper;
import com.qf.service.IUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UsersServiceImpl implements IUsersService {

    private UsersMapper usersMapper;
    @Autowired
    public void setUsersMapper(UsersMapper usersMapper) {
        this.usersMapper = usersMapper;
    }

    @Override
    public int addUser(UsersDto users) {

        String salt = Md5.RandomSalt();
        String salfpassword = Md5.Md5AndSalt(salt, users.getPassword());
        System.out.println("加盐了"+salt);
        users.setPassword(salfpassword);
        users.setPasswordsalt(salt);

        int i = usersMapper.addUser(users);
        return i;
    }
}
